home *** CD-ROM | disk | FTP | other *** search
- <![CDATA[
-
- /*
- Image Resolver code.
-
- Typical XSL markup usage looks like the following:
-
- <xsl:choose>
- <xsl:when expr="goImage.Lookup('img_ieget_animated', goCtx)">
- <IMG BORDER="0">
- <xsl:attribute name="SRC"><xsl:eval>goImage.GetHREF()</xsl:eval></xsl:attribute>
- <xsl:attribute name="ALT"><xsl:eval>goImage.GetName()</xsl:eval></xsl:attribute>
- <xsl:attribute name="HEIGHT"><xsl:eval>goImage.GetHeight()</xsl:eval></xsl:attribute>
- <xsl:attribute name="WIDTH"><xsl:eval>goImage.GetWidth()</xsl:eval></xsl:attribute>
- </IMG>
- </xsl:when>
- <xsl:otherwise><SPAN CLASS="clsBadImg"><xsl:eval>goImage.GetError()</xsl:eval></SPAN></xsl:otherwise>
- </xsl:choose>
-
- */
-
- function CImage(oCtx)
- {
- this._oCtx = oCtx;
- this._lastRID = null;
- this._lastImg = null;
- }
-
- CImage.prototype.Init = function()
- {
- var vPropName;
- for (vPropName in this)
- {
- if (typeof(this[vPropName]) != 'function')
- {
- delete(this[vPropName]);
- }
- }
- }
-
- CImage.prototype.Lookup = function(sRID, oCtx)
- {
- if (!sRID)
- {
- this._error = "must specify rid to lookup image";
- return false;
- }
-
- // did we just look it up?
- if (sRID == this._lastRID)
- {
- return true;
- }
-
- // cache images
- if (typeof(this._table) == 'undefined')
- {
- this._table = new Array();
- }
-
- // see if the image has already been looked up
- this._lastImg = this._table[sRID];
- if (!this._lastImg)
- {
- var oImgNode = ownerDocument.selectSingleNode("/inetsdk:topic/inetsdk:images/image[@id='" + sRID + "']");
- if (!oImgNode)
- {
- this._error = "image not found (" + sRID + ")";
- return false;
- }
-
- this._lastImg = this._table[sRID] = new Object();
-
- this._lastImg.name = oImgNode.getAttribute("name");
- this._lastImg.height = oImgNode.getAttribute("height");
- this._lastImg.width = oImgNode.getAttribute("width");
-
- var sHREF = oImgNode.getAttribute("href");
-
- //at: if (oCtx && (oCtx._media == 'chm' || oCtx._media == 'hxs'))
- if (oCtx && (oCtx._media == 'chm'))
- {
- if (!goTD.Ensure())
- {
- this._error = goTD.GetError();
- return false;
- }
-
- this._lastImg.href = MakeRelative(goTD.GetHREF(), sHREF);
- if (!this._lastImg.href)
- {
- this._error = "VROOT2Relative failure.";
- return false;
- }
- }
- else
- {
- this._lastImg.href = sHREF;
- }
-
- }
-
- this._lastRID = sRID;
-
- return true;
- }
-
- // return the name of the image for its ALT text
- CImage.prototype.GetName = function()
- {
- return (typeof(this._lastImg.name) != 'undefined' ? this._lastImg.name : '');
- }
-
- // return the SRC for the image
- CImage.prototype.GetHREF = function()
- {
- return (typeof(this._lastImg.href) != 'undefined' ? this._lastImg.href : '');
- }
-
- // return the optimum width of the image
- CImage.prototype.GetWidth = function()
- {
- return (typeof(this._lastImg.width) != 'undefined' ? this._lastImg.width : '');
- }
-
- // return the optimum height of the image
- CImage.prototype.GetHeight = function()
- {
- return (typeof(this._lastImg.height) != 'undefined' ? this._lastImg.height : '');
- }
-
- // return the last error that occurred during image lookup
- CImage.prototype.GetError = function()
- {
- return (typeof(this._error) != 'undefined' ? this._error : '');
- }
-
- ]]>
-